﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace QLVT2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class HoaDonWindow : Window
    {
        public HoaDonWindow()
        {
            InitializeComponent();
        }
        private HoaDon hoadon = new HoaDon();
        private HoaDon hd = new HoaDon();
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            DataTable dt = hoadon.DanhSachHoaDon();
            datagrid.ItemsSource = dt.DefaultView; 
            datagrid.SelectedValuePath = "sohd";
        }

        private void btClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void xoa_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Bạn có muốn xoa không?", "Thông Báo", MessageBoxButton.YesNo, MessageBoxImage.Warning);
            if (result == MessageBoxResult.Yes)
            {
                string shd = datagrid.SelectedValuePath.ToString();
                hd.XoaHoaDon(shd);
                DataRowView rowselect = (DataRowView)datagrid.SelectedItem;
                rowselect.Delete();
            }          
        }

    }
}
